<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%-- <%@include file="../../common/taglib/taglib.jsp"%> --%>
<form id="pagerForm" method="post" action="${baseURL }/tqInfo/list">
    <%@include file="../common/pageParameter.jsp" %>
</form>
<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="${baseURL }/tqInfo/list"
		method="post">
		<div class="searchBar">
			<table class="searchContent">
				<tr>
				    <td>台签编号：<input type="text" name="tqNo"
					    alt="请输入台签编号" value="${param.tqNo}" />
					</td>
					<td>商户编号：<input type="text" name="merchant.userNo" value="${merchantNo}" />
					</td>
					<td>
					    <a class="btnLook" href="${baseURL}/user/info/lookupList?userType=MERCHANT" lookupGroup="merchant">选择商户</a>
					</td>
					<td>代理商编号：<input type="text" id="agentNo" name="agent.userNo" value="${agentNo}" />
					</td>
					<td>
					    <a class="btnLook" href="${baseURL}/user/info/lookupList?userType=AGENT" lookupGroup="agent">选择代理商</a>
					</td>
					<td>状态：
                        <select name="status">
                            <option value="">--请选择--</option>
                            <option value="UN_ALLOT" <c:if test="${param.status == 'UN_ALLOT'}">selected="selected"</c:if> >未被分派</option>
                            <option value="ALLOTTED" <c:if test="${param.status == 'ALLOTTED'}">selected="selected"</c:if> >已被分派</option>
                            <option value="IS_BINDING" <c:if test="${param.status == 'IS_BINDING'}">selected="selected"</c:if> >已被绑定</option>
                            <option value="CANCEL" <c:if test="${param.status == 'CANCEL'}">selected="selected"</c:if> >已作废</option>
                        </select>
					</td>
                    <td>
						<div class="buttonActive">
							<div class="buttonContent">
							     <button title="查询" type="submit">查&nbsp;询</button>
							</div>
						</div>
					</td>
                 </tr>
			</table>
		</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
		    <shiro:hasPermission name="tq:tqInfo:add">
			<li>
				<a title="批量添加台签" class="add"
					href="${baseURL }/jsp/tqInfo/add.jsp" target="dialog" mask="true"
				    width="550" height="240"><span>批量添加台签</span>
				</a>
			</li>
			<li class="line">line</li>
			</shiro:hasPermission>
			<c:if test="${unAllotCount > 0}">
			<shiro:hasPermission name="tq:tqInfo:allotted">
			<li>
				<a title="批量分派台签" class="edit"
					href="${baseURL }/tqInfo/allottedUI" target="navTab">
					<span>批量分派台签</span>
				</a>
			</li>
			<li class="line">line</li>
			</shiro:hasPermission>
			</c:if>
			<shiro:hasPermission name="tq:tqInfo:export">
			<li>
				<a id="exportTq" class="icon" href="javascript:;" onClick="exportTq()" 
					title="确认导出已分派台签吗?">
					<span>导出已分派台签</span>
				</a>
			</li>
			</shiro:hasPermission>
			<li class="line">line</li>
			<span style="color: blue;">台签总数：${pageBean.totalCount}（张）</span>
		    <li class="line">line</li>
		    <span style="color: red;">未分派数：${unAllotCount}（张）</span>
		    <li class="line">line</li>
		    <span style="color: mauve;">已被分派：${allottedCount}（张）</span>
		    <li class="line">line</li>
		    <span style="color: green;">已绑定数：${bindingCount}（张）</span> 
		    <li class="line">line</li>   
		    <span style="color: gray;">已取消数：${cancelCount}（张）</span>
		</ul>
	</div>
	<table class="table" width="101%" layoutH="109">
		<thead>
			<tr>
				<th>序号</th>
				<th>台签编号</th>
				<th>代理商编号</th>
				<th>代理商名称</th>
				<th>二维码</th>
				<th>状态</th>
				<th>创建时间</th>
				<th>商户编号</th>
				<th>商户名称</th>
				<th>合同号</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="item" items="${pageBean.recordList}" varStatus="s">
				<tr>
					<td>${s.index + 1}</td>
					<td>${item.tqNo}</td>
					<td>
					    ${item.agentNo}<br/>
					    <c:if test="${item.secondAgentNo !=null && item.secondAgentNo !='' }">&nbsp;&nbsp;&nbsp;&nbsp;|--&nbsp;&nbsp;${item.secondAgentNo}<br/></c:if>
					    <c:if test="${item.thirdAgentNo !=null && item.thirdAgentNo !='' }">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--&nbsp;&nbsp;${item.thirdAgentNo}</c:if>
					</td>
					<td>
					    ${item.agentName}<br/>
					    <c:if test="${item.secondAgentName !=null && item.secondAgentName !='' }">&nbsp;&nbsp;&nbsp;&nbsp;|--&nbsp;&nbsp;${item.secondAgentName}<br/></c:if>
					    <c:if test="${item.thirdAgentName !=null && item.thirdAgentName !='' }">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--&nbsp;&nbsp;${item.thirdAgentName}</c:if>
					</td>
					<td>
					    <c:if test="${item.imgUrl !=null }">
					       <img style="height:90px;width: 90px;" src="${item.imgUrl }"/>
					    </c:if>
					</td>
					<td>
					    <c:if test="${item.status == 'UN_ALLOT'}"><span style="line-height: 21px; color: green;">未被分派</span></c:if>
					    <c:if test="${item.status == 'ALLOTTED'}"><span style="line-height: 21px; color: blue;">已被分派</span></c:if>
					    <c:if test="${item.status == 'IS_BINDING'}"><span style="line-height: 21px; color: black;">已被绑定</span></c:if>
					    <c:if test="${item.status == 'CANCEL'}"><span style="line-height: 21px; color: red">已作废</span></c:if>
					</td>
					<td><fmt:formatDate value="${item.createTime}"
					     pattern="yyyy-MM-dd HH:mm:ss" />
			        </td>
			        <td>${item.merchantNo}</td>
					<td>${item.merchantName}</td>
					<td>${item.contractNo}</td>
			        <td>
			            <shiro:hasPermission name="tq:tqInfo:view">
				            [<a title="台签信息详情" target="navTab" href="${baseURL }/tqInfo/viewUI?id=${item.id}" style="color: blue;">查看</a>]
				        </shiro:hasPermission>
				        <shiro:hasPermission name="tq:tqInfo:edit">
				        <c:if test="${item.status == 'IS_BINDING'}">
				            &nbsp;[<a href="${baseURL}/tqInfo/status?id=${item.id}&status=CANCEL" title="确定要作废该台签吗？" target="ajaxTodo" style="color: red">作废</a>]
				        </c:if>
				        </shiro:hasPermission>
			        </td>
				</tr>
			</c:forEach>
			<c:if test="${pageBean.totalCount==0}"><tr><td>暂无数据</td></tr></c:if>
		</tbody>
	</table>
	<%@include file="../common/pageBar.jsp" %>
</div>
<script language="javaScript">    
	//导出已分派台签
	function exportTq(){
	    var agentNo = $("#agentNo").val();
	    if(agentNo == ""){
	    	alert("请选择代理商");
	    }else{
	    	window.location.href = "${baseURL }/tqInfo/exportTq?agentNo="+agentNo;
	    }
	}
</script>